package cn.lopr.im.socketserver.constant;

public class Const {
    public final int ONLINE = 1;
    public static final String Host = "localhost:8080";
    public static final String SEND_OFFLINE_MESSAGE = String.format("http://%s/im/message/addMessage", Host);

    public enum MessageType {
        USER_ONLINE(0, "用户上线"),
        SEND_TO_USER(1, "发送给用户"),
        SEND_TO_GROUP(2, "发送给组"),
        SEND_ADD(3, "发送添加好友信息");

        private final int code;
        private final String desc;

        MessageType(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static MessageType getTypeByCode(int code) {
            for (MessageType value : values()) {
                if (value.getCode() == code) {
                    return value;
                }
            }

            return null;
        }
    }
}